<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增回复')"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-response-add" th:object="${wxRequest}">
        <input name="qqid" th:field="*{qqid}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">回复内容：</label>
            <div class="col-sm-8">
                <input name="hfnr" class="form-control" type="text" required>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<script type="text/javascript">
    var prefix = ctx + "control/response";

    $("#form-response-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            save(prefix + "/add", $('#form-response-add').serialize(), function (res) {
                if(res.success){
                    $.modal.close();
                    window.parent.parent.$.modal.openTab("呼应-回复", $.common.setURL("/control/response"));
                }
            });
        }
    }

    function save(url, data, callback) {
        var config = {
            url: url,
            type: "post",
            dataType: "json",
            data: data,
            beforeSend: function (request) {
                request.setRequestHeader("X-Access-Token", storage.get("token"));
            },
            success: function(result) {
                callback(result);
            }
        };
        $.ajax(config)
    }

</script>
</body>
</html>
